package com.example.secondhandsysapi.Mapper;

import com.example.secondhandsysapi.Vo.CollectionDetails;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface CollectMapper {

    @Select("INSERT INTO collect_info(user_id, goods_id, create_date) VALUES ( #{user_id}, #{goods_id}, NOW())")
    Integer getCollects(@Param("user_id") Integer user_id, @Param("goods_id") Integer goods_id);

    @Select("select collection_id,collect_info.user_id,collect_info.goods_id,collect_info.create_date,goods_name,goods_price,goods_image \n" +
            "from collect_info join goods_info on collect_info.goods_id=goods_info.goods_id \n" +
            "where collect_info.user_id=#{user_id} and goods_name like '%${goods_name}%'")
    List<CollectionDetails> getCollectionInfoByName(@Param("user_id") Integer user_id, @Param("goods_name") String goods_name);

    @Select("select collection_id,collect_info.user_id,collect_info.goods_id,collect_info.create_date,goods_name,goods_price,goods_image \n" +
            "from collect_info join goods_info on collect_info.goods_id=goods_info.goods_id \n" +
            "where collect_info.user_id=#{user_id} ")
    List<CollectionDetails> getCollectionInfo(@Param("user_id") Integer user_id);
}
